<?php
$this->breadcrumbs=array(
	Shop::t('Products'),
);
Shop::renderFlash();
?>
<div><?php echo $intro;?></div>
<br />
<?php 
foreach($model as $key => $data) {
    $data['price'] = intval(($data['price'])?$data['price'] + $data['frame']['price_adjustion']:$data['price']);
    $data['new_price'] = intval(($data['new_price'])?$data['new_price'] + $data['frame']['price_adjustion']:$data['new_price']);
?>
    <?php if($key % 3 == 0) echo '<div class="main-product"><ul>';?>
            <li>
                <?php
                    $isSpecial = Yii::app()->request->getQuery('special');
                    if($isSpecial && $data['is_special']) {?><div class="special"></div><?php }?>
                <a href="<?php echo $this->createUrl('/shop/products/view', array('id' => $data['product_id']));?>">
                    <img src="<?php echo Yii::app()->request->baseUrl; ?>/data/upload/products/<?php echo isset($data->shopImages[count($data->shopImages)-1]) ? $data->shopImages[count($data->shopImages)-1]->filename : 'no_image.jpg'?>" width="260" height="260" alt="product01">
                    <div class="clearfix">
                        <h3><?php echo StringHelper::substr($data['title'], 0, 24);?></h3>
                    	<p><?php echo StringHelper::substr(strip_tags($data['description']), 0, 120);?></p>
                        <?php if ($data['price'] && $data['new_price']) { ?>
                            <span class="old-price">$<?php echo $data['price'] ?></span>
                            <span class="new-price">$<?php echo $data['new_price'] ?></span>
                        <?php } else {?>
                            <span class="new-price">$<?php echo ($data['price'])?$data['price']:''; ?></span>
                        <?php }?>                       
                    </div>
                </a>
            </li>
    <?php if($key % 3 == 2) echo '</div></ul>';?>
<?php }?>
<?php if($item_count):?>
<div class="paging-block">
        <p>Displaying <?php echo $pages->getCurrentPage()* $page_size +1;?>  to <?php echo ($item_count >= (($pages->getCurrentPage()+1) * $page_size))?($pages->getCurrentPage()+1) * $page_size : $item_count;?> (of <?php echo $item_count?> products)</p>

        <div class="pages">
            <?php
            // the pagination widget with some options to mess
            $this->widget('MyLinkPager', array(
                'currentPage' => $pages->getCurrentPage(),
                'itemCount' => $item_count,
                'pageSize' => $page_size,
                'maxButtonCount' => 5,
                'header' => '',
                'htmlOptions' => array('class' => 'pages'),
            ));
            ?>
        </div>
    </div>
<?php endif;?>